package demo.controller;

import demo.service.IDemoService;
import mvc.annotations.MyAutowired;
import mvc.annotations.MyController;
import mvc.annotations.MyRequestMapping;
import mvc.annotations.MyService;
import mvc.filter.filters.Security.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@MyController
@Security({"all", "base"})
@MyRequestMapping("/demo")
public class DemoController {


    @MyAutowired
    private IDemoService demoService;


    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param name
     * @return
     */
    @MyRequestMapping("/query")
    @Security({"all", "sub"})
    public String query(HttpServletRequest request, HttpServletResponse response,String name) throws IOException {
        response.getWriter().write("success");
        return demoService.get(name);
    }

    @MyRequestMapping("/query1")
    public String query1(HttpServletRequest request, HttpServletResponse response,String name) throws IOException {
        response.getWriter().write("success");
        return demoService.get(name);
    }
}
